from mongoengine import Document, StringField, DateTimeField
from datetime import datetime

class User(Document):
    """用户模型"""
    username = StringField(max_length=50, required=True, unique=True)
    password = StringField(max_length=200, required=True)
    created_at = DateTimeField(default=datetime.now)
    
    meta = {
        'collection': 'users'
    }
    
    def __str__(self):
        return self.username

class Major(Document):
    """专业信息模型"""
    name = StringField(max_length=100, required=True)
    code = StringField(max_length=20, required=True)
    
    meta = {
        'collection': 'majors'
    }
    
    def __str__(self):
        return self.name
